package org.smartcti.freeswitch.inbound.internal;

import java.io.IOException;

import org.smartcti.freeswitch.util.SocketConnectionFacade;


/**
 * The ManagerReader reads events and responses from the asterisk server, parses
 * them using EventBuilderImpl and ResponseBuilder and dispatches them to the
 * associated ManagerConnection.<p>
 * Do not use this interface in your code, it is intended to be used only by the
 * DefaultManagerConnection.
 *
 * @author srt
 * @version $Id: ManagerReader.java,v 1.2 2008/11/19 12:45:36 erik.han Exp $
 * @see org.asteriskjava.manager.internal.EventBuilder
 * @see org.asteriskjava.manager.internal.ResponseBuilder
 * @see org.asteriskjava.manager.DefaultManagerConnection
 */
public interface InboundReader extends Runnable
{
    String COMMAND_RESULT_RESPONSE_KEY = "__result__";

    /**
     * Sets the socket to use for reading from the asterisk server.
     *
     * @param socket the socket to use for reading from the asterisk server.
     */
    void setSocket(final SocketConnectionFacade socket);

   
    /**
     * Terminates this reader.
     */
    void die();

    /**
     * Checks whether this reader is terminating or terminated.
     *
     * @return <code>true</code> if this reader is terminating or terminated,
     *         <code>false</code> otherwise.
     */
    boolean isDead();

    /**
     * Returns the Exception that caused this reader to terminate if any.
     *
     * @return the Exception that caused this reader to terminate if any or <code>null</code> if not.
     */
    IOException getTerminationException();
}
